<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../myVue/vue.js"></script>
</head>
<body>
    <div id="app">
        <p>单价:{{price}}</p>
        <p>数量:{{num}}</p>
        <p>总价:{{toPrice}}</p>

        <button @click="num==0?0:num--">减少数量</button>
        <button @click="num++">增加数量</button>
    </div>
</body>
<script>
    var vm=new Vue({
        el:"#app",
        data:{
            price:234,
            num:0
        },
        computed:{
            toPrice:function(){
                return this.price*this.num
            }
        },
        methods:{

        }
    })
</script>
</html>